<!-- 公共文件 start -->
@extends('admin.public.base')
<!-- 公共文件 end -->
<style>
    table th {
        min-width: 10px !important;
    }
    .layui-card-header {
        padding-top: 10px !important;
    }
</style>
@section('content')
    <div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">财务报表</a>
        <a><cite>代理商年报</cite></a>
    </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-inline layui-show-xs-block">
                                <select name="store_id">
                                    <option value=""></option>
                                    @foreach($stores as $val)
                                        @if(request()->input('store_id') == $val['id'])
                                            <option value="{{$val['id']}}" selected>{{$val['store_name']}}</option>
                                        @else
                                            <option value="{{$val['id']}}">{{$val['store_name']}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="year" id="year" placeholder="请选择年份" value="{{request()->input('start')}}">
                                </div>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button id="search" class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;搜索</i>
                                </button>
                                <input type="hidden" id="export_excel" name="export_excel" value="0">
                                <button id="export_excel_btn" class="layui-btn" lay-submit="" lay-filter="sreach"><i
                                        class="layui-icon">&#xe65b;</i>导出Excel
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body">
                        {{--{{$store['store_name']}}--}}
                        <table class="layui-table layui-form" style="width: 100%">
                            <thead>
                            <tr>
                                @foreach($title as $t)
                                    <th>{{$t}}</th>
                                @endforeach
                            </thead>
                            <tbody>
                            @foreach($data as $k=>$item)
                                @if($k == 3 || $k == 7 || $k == 8 || $k == 12 || $k == 16 || $k == 17 || $k == 18)
                                    <tr style="background-color: #ffffff">
                                        @foreach($item as $i)
                                            <td>{{$i}}</td>
                                        @endforeach
                                    </tr>
                                @else
                                    <tr>
                                        @foreach($item as $i)
                                            <td>{{$i}}</td>
                                        @endforeach
                                    </tr>
                                @endif
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['laydate', 'form'], function(){
            form = layui.form,laydate = layui.laydate;

            //年选择器
            laydate.render({
                elem: '#year'
                ,type: 'year'
            });
        });

        $("#export_excel_btn").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(1)
        });
        $("#search").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(0);
        });
    </script>
@endsection
